import { getBaseRollupPlugins, getPackageJson, resolvePkgPath } from "./utlis"
import generatePackageJson from "rollup-plugin-generate-package-json";
const { name, module } = getPackageJson('react');
const pkgPath = resolvePkgPath(name)
const distPath = resolvePkgPath(name, true)
export default [
    {
        input: `${pkgPath}/${module}`,
        output: {
            file: `${distPath}/index.js`,
            format: 'umd',
            sourcemap: true,
            name: 'index.js',
            globals: {
                react: 'React'
            }
        },
        plugins: [...getBaseRollupPlugins(), generatePackageJson({
            inputFolder: pkgPath,
            outputFolder: distPath,
            baseContents({ name, version, description }) {
                return {
                    name,
                    version,
                    description,
                    main: 'index.js',
                }
            }
        })]
    },
    //jsx-runtime
    {
        input: `${pkgPath}/src/jsx.ts`,
        output: [
            {
                file: `${distPath}/jsx-runtime.js`,
                format: 'umd',
                sourcemap: true,
                name: 'jsx-runtime.js',
            },
            {
                file: `${distPath}/jsx-dev-runtime.js`,
                format: 'umd',
                sourcemap: true,
                name: 'jsx-dev-runtime.js',
            }
        ],
        plugins: getBaseRollupPlugins()
    }
]